home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1990: Discy Business / Discy Business.2mg / DEV.CD / GUIDED.TOURS / IIC.PLUS.TOUR / BASIC / SAVER.TEXT < prev    next >
Encoding:
Text File  |  1988-04-09  |  5.3 KB  |  371 lines  |  [04] ASCII Text (0x0000)

  1. %
  2. 3
  3. 10
  4. 1
  5. 38
  6.         SAVING PROGRAMS
  7.  
  8. In the last section, you wrote a
  9. computer program that prints four
  10. lines of heartfelt verse.
  11. ^
  12. %
  13. 3
  14. 8
  15. 1
  16. 38
  17. To review what your program looks
  18. like, type LIST.
  19. ^
  20. %
  21. 3
  22. 8
  23. 1
  24. 38
  25. There it is!  Your famous first
  26. words.  Right now, your program is
  27. stored in the computer's memory.
  28. ^
  29. %
  30. 3
  31. 10
  32. 1
  33. 38
  34. But if you or some unsuspecting
  35. friend turns off your computer,
  36. the program will be gone forever,
  37. or at least gone until you get
  38. around to retyping it.
  39. ^
  40. &
  41. Rather than having to retype your
  42. programs each time you turn on
  43. the computer, you can use the SAVE
  44. command to save your programs on a
  45. disk.
  46. ^
  47. &
  48. Then, when you're ready to run a
  49. program, you can use the LOAD
  50. command to load the program
  51. back into the computer's memory.
  52. ^
  53. &
  54. When you give the SAVE command,
  55. your computer copies the program
  56. in memory into a file on the disk
  57. in your disk drive.
  58. ^
  59. &
  60. To keep programs from getting
  61. mixed up when you store them on
  62. the disk, you must give each
  63. program a different name.
  64. ^
  65. %
  66. 3
  67. 9
  68. 1
  69. 38
  70. Let's name your program POEM.  To
  71. store POEM on the disk, type...
  72.  
  73. SAVE POEM     (and press RETURN)
  74. ^
  75. %
  76. 3
  77. 9
  78. 1
  79. 38
  80. Good job!  You've just saved a
  81. program.  Notice that after you
  82. give the SAVE command, the disk
  83. use light turns on.
  84. ^
  85. &
  86. When the light turns off, you know
  87. your program is stored safely on
  88. the disk as well as in the
  89. computer's memory.
  90. ^
  91. &
  92. Press RETURN for a demonstration
  93. of what happens when you use the
  94. SAVE command.
  95. ^
  96. %
  97. 20
  98. 24
  99. 1
  100. 38
  101. This is a picture of an Apple II
  102. with an external disk drive.
  103. ^
  104. &
  105. When you write your program, it
  106. goes into the computer's memory.
  107. ^
  108. &
  109. SAVE copies the program in memory
  110. onto the disk in the disk drive.
  111. ^
  112. &
  113. Notice, however, that the
  114. program is still in memory.
  115. ^
  116. &
  117. The SAVE command doesn't erase
  118. the computer's memory.
  119. ^
  120. %
  121. 3
  122. 9
  123. 1
  124. 38
  125. But let's say you're basically a
  126. suspicious sort who wants hard
  127. proof that the program is really
  128. on the disk.
  129. ^
  130. &
  131. Well, lucky for you, your disk
  132. keeps track of all the programs
  133. it contains.  It keeps them in a
  134. catalog.
  135. ^
  136. %
  137. 3
  138. 10
  139. 1
  140. 38
  141. CAT is the command you use to
  142. display the catalog.  Try it now.
  143. Type...
  144.  
  145. CAT           (and press RETURN)
  146. ^
  147. %
  148. 3
  149. 11
  150. 1
  151. 38
  152. There's the catalog.  As you can
  153. see, you've only saved one
  154. program (POEM) on your simulation
  155. disk so far.  (Don't worry about
  156. the numbers after the names.  They
  157. aren't important right now.)
  158. ^
  159. %
  160. 3
  161. 9
  162. 1
  163. 38
  164. Since your program is now saved
  165. on the disk, you can erase it from
  166. the computer's memory and it will
  167. remain on the disk.
  168. ^
  169. &
  170. You use the NEW command to erase
  171. a program from memory.  It's
  172. called NEW because it lets you
  173. make room for a new program.
  174. ^
  175. &
  176. Why don't you try it now?  Type
  177.  
  178. NEW         (and press RETURN)
  179. ^
  180. %
  181. 3
  182. 9
  183. 1
  184. 38
  185. There.  Your program is no
  186. longer in memory.  But don't take
  187. our word for it.  Try running
  188. your program.
  189. ^
  190. %
  191. 3
  192. 7
  193. 1
  194. 38
  195. Surprise!  Nothing happens because
  196. the program is gone from memory.
  197. ^
  198. &
  199. Press RETURN and we'll show you
  200. what happened to your program.
  201. ^
  202. %
  203. 20
  204. 24
  205. 1
  206. 38
  207. Your program was in memory
  208. and was also saved on the disk.
  209. ^
  210. &
  211. When you typed NEW, the program
  212. was erased from memory.
  213. ^
  214. &
  215. However, the copy of the program
  216. on the disk remains.
  217. ^
  218. %
  219. 3
  220. 11
  221. 1
  222. 38
  223. At this point you could start
  224. writing another program.  But
  225. let's suppose that you're suddenly
  226. overcome with the desire to make
  227. your verse even more poetic.
  228. ^
  229. &
  230. Your first task is to get a copy
  231. of your program from the disk and
  232. put it in the computer's memory.
  233. To do this, you use the LOAD
  234. command, followed by the name of
  235. the program you want to work on.
  236. ^
  237. %
  238. 3
  239. 9
  240. 1
  241. 38
  242. You saved your program as POEM.
  243. So type:
  244.  
  245. LOAD POEM    (and press RETURN)
  246. ^
  247. %
  248. 3
  249. 9
  250. 1
  251. 38
  252. Excellent!  Your POEM program
  253. is back in memory!  Press RETURN
  254. and we'll show you how it got
  255. there.
  256. ^
  257. %
  258. 20
  259. 24
  260. 1
  261. 38
  262. Your POEM program was saved on
  263. the disk.
  264. ^
  265. &
  266. When you loaded it, a copy of the
  267. program was sent to memory.
  268. ^
  269. &
  270. But notice that the original
  271. program stayed on the disk.
  272. ^
  273. %
  274. 3
  275. 8
  276. 1
  277. 38
  278. Try listing your program now (to
  279. make certain that it's really
  280. there).
  281. ^
  282. %
  283. 3
  284. 9
  285. 1
  286. 38
  287. There it is, the same poem you
  288. saved at the beginning of
  289. this section.  And remember, the
  290. original is still on the disk.
  291. ^
  292. %
  293. 3
  294. 10
  295. 1
  296. 38
  297. Now that your program is back in
  298. memory, why don't you change line
  299. 30 (press RETURN for a hint if you
  300. don't remember how to change a
  301. line).
  302. ^
  303. %
  304. 3
  305. 11
  306. 1
  307. 38
  308. Great job.  Clearly this is a
  309. verse worth saving.  You already
  310. have one program on the disk.  If
  311. you were to save this program
  312. under the same name, the new pro-
  313. gram would replace the old one.
  314. ^
  315. %
  316. 3
  317. 9
  318. 1
  319. 38
  320. Because you want to save both
  321. programs, you should save this one
  322. under some other name.  Go ahead,
  323. save your modified poem now.
  324. ^
  325. %
  326. 3
  327. 9
  328. 1
  329. 38
  330. Congratulations!  Now catalog the
  331. disk just to make sure that both
  332. poems are tucked away safely on
  333. the disk.
  334. ^
  335. %
  336. 3
  337. 12
  338. 1
  339. 38
  340. Sure enough!  Both programs are
  341. there.  Just one small request
  342. before we go on.  If you ever get
  343. either of these wonderful poems
  344. published, please give Apple
  345. credit for providing the
  346. inspiration.
  347. ^
  348. &
  349. You have learned a whole lot so
  350. far.  You now know how to write
  351. and change simple BASIC programs,
  352. how to save them on a disk, how
  353. to check the contents of a disk,
  354. and how to load programs into
  355. memory.
  356. ^
  357. &
  358. At this point, you may want to
  359. continue with the next section, or
  360. you may want to stop and practice
  361. writing and saving some programs
  362. of your own.
  363. ^
  364. &
  365. If you want to practice,
  366. press ESC to go to the menu,
  367. then select Quit.  Otherwise,
  368. press RETURN to learn more about
  369. programming in BASIC.
  370. ^
  371.